#! /bin/env python3
# coding: utf-8

from common.py_zabbix import *

config = load_cfg()
if config["DEBUG"] == True:
    enable_debug("pyzabbix")
user = config["ZBX_INFO"]["user"]
pwd = config["ZBX_INFO"]["pwd"]
url = config["ZBX_INFO"]["url"]
groups = config["MONITOR_INFO"]["groups"]
templateId = config["MONITOR_INFO"]["templateId"]
zbx = zbx(user, pwd, url)

with open("host_info") as f:
    for line in f:
        if not line:
            break
        else:
            info = line.split(",")
            hostIds=zbx.create_host(info[0], groups, templateId)
            #add zbbix agent monitor
            interfaceIds=zbx.create_hostInterface(hostIds,info[1],10050,1)
            #add jmx monitor
            #zbx.create_hostInterface(hostids,info[1],12345,4)
            proxyIds=zbx.create_proxy(hostIds)

